<template>
      <el-container class="section pdbot_none">
        <el-main>
          <el-container>
            <vxe-modal v-model="addFl" :title="flTitle">
                <form-panel
                    ref="tcclsTjfl"  
                    height="300" 
                    templet="DIC_TABLE"
                    :form-type="isNew"
                    :buttons="mangerformbuttons"
                    @closehandler="close" />
            </vxe-modal>
            <el-aside class="relative side_width">
              <el-container>
                <el-header class="height_auto pdbt" style="padding:4px;">
                <el-row>
                    <el-col :span="12">
                    <vxe-input v-model="orgschval" id="treeSreach" placeholder="请输入关键字" type="search" size="mini"
                                @keyup.enter.native="searchTree" class="input_bk" @search-click="searchTree">
                    </vxe-input>
                    </el-col>
                    <el-col :span="6" style="text-align: right;" class="min_btn">
                    <!-- <el-tooltip class="item" content="增加标签" effect="light" placement="top-start">
                        <el-button size="mini"
                                type="text"
                                icon="el-icon-folder-add"
                                name="增加标签"
                                @click="addBq"
                        ></el-button>
                    </el-tooltip> -->
                    <el-tooltip class="item" content="增加" effect="light" placement="top-start">
                        <el-button size="mini"
                                type="text"
                                icon="el-icon-plus"
                                name="增加"
                                @click="addFenLei"
                        ></el-button>
                    </el-tooltip>
                    <el-tooltip class="item" content="编辑" effect="light" placement="top-start">
                        <el-button size="mini"
                                type="text"
                                icon="fa fa-edit"
                                name="编辑"
                                @click="editFenLei"
                        ></el-button>
                    </el-tooltip>
                    <!-- <el-tooltip class="item" content="修改分类" effect="light" placement="top-start">
                        <el-button size="mini"
                                type="text"
                                icon="el-icon-edit-outline"
                                name="修改"
                                @click="editFenLei"
                        ></el-button>
                    </el-tooltip> -->
                    <el-tooltip class="item" content="刷新树" effect="light" placement="top-start">
                        <el-button
                        type="text"
                        icon="el-icon-refresh"
                        size="mini"
                        @click="refresh"
                        >
                        </el-button>
                    </el-tooltip>
                    </el-col>
                </el-row>
                </el-header>
                <el-main>
                <ps-tree ref="leftTree"
                        :tree-comp-data="treeComp"
                        @onTreeClick="treeClick"
                        @refresh="refresh"
                        @createRightMenu="createRightMenu"
                        @onTreeDrop="flglTreeDrop"
                        @onAsyncSuccess="sonAsyncSuccess"/>
                </el-main>
              </el-container>
            </el-aside>
            
            <el-main class="relative clear_padding">
              
            </el-main>
          </el-container>
        </el-main>
      </el-container>
</template>

<script>
import request from "@/utils/requestutil";
import formPanel from '@/components/formpanel';
import psTree from '@/components/psTree/psTree';
export default {
  props:{
  },
  components: {
    psTree,
    formPanel
  },
  data() {
    return {
        mangerformbuttons: ['save', 'close'],
        flTitle: '',
        addFl: false,
        isNew: '',
        treeComp: {
          treeConfigKey: 'V_DIC_TABLE_TREE2',
          treeBuildConfig: {
            dealTreaparam: this.dealTreaparam,
            dataFilter: this.datafilter,
            beforeDrop: this.beforeDrop,
            onExpand: this.onExpand
          }
        },
    }
  },
  created() {
  },
  mounted(){
  },
  watch: {
  },
  methods: {
    treeClick(e, treeid, node){
      debugger
      var seachObj = {}
      seachObj.id = node.mainTable
      this.$emit("tbFieldClick", seachObj);
    },
    //刷新树
    refresh(){
        this.$refs.leftTree.refresh();
    },
    editFenLei(){
        this.flTitle = '编辑'
        this.addFl = true
        this.isNew = 'edit'
    },
    close(){
        this.addFl=false
    },
    //添加分类
    addFenLei(){
        this.flTitle = '添加'
        this.addFl = true
        this.isNew = 'new'
        // let node = this.$refs.leftTree.ztreeObj.getSelectedNodes();
        // if (node.length == 0) {
        //     this.$message.warning("请选择新增位置！")
        //     return
        // } else if (node[0].tcIsTag == "0") {
        //     this.fLpid = node[0].ftcCd
        // } else {
        //     this.fLpid = node[0].tcCd
        // }
    },
    dealTreaparam(treeid, node){
        //   const _that = this;
        //   let param = {};
        //   param = {p0: _that.BZCODE};

        //   if (!this.$_.isEmpty(_that.orgschval)) {
        //     param.name = _that.orgschval;
        //     param.isSearch = true;
        //     this.second=false
        //   } else if (node == undefined || node == "") {
        //     this.second=true
        //     param.pid = "root";
        //   } else {
        //     this.second=false
        //     param.pid = node.id;
        //   }
        //   return param;
    },
    datafilter(treeid, pnode, resdata) {
        debugger
        this.allNode=resdata.data;
        let t = this
        if (resdata && resdata.data && resdata.data.length > 0) {
            let _val = t.value ? t.value.split(",") : [];
            t.$_.forEach(resdata.data, (item, val) => {
                if (item.leaf == '0') item.isParent = true
            })
        } else {
            if (pnode)
            pnode.isParent = false;
        }
        return resdata.data;
    },
  }
};
</script>
<style scoped>
</style>
